<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    .parent{
      position: relative;
      height: 500px;
      width: 500px;
      background-color: red;
    }
    .child{
      position: absolute;
      height: 40px;
      width: 40px;
      background-color: blue;
      /* top:0; */
      /* top: 150px;
      left: 250px; */
      /* top:50%; */
      /* bottom: 0; */
      /* right: 0; */
      /* left: 50%;
      margin-left:-20px;
      margin-top: -20px; */
      left: 0;
      right: 0;
      top: 0;
      bottom: 0;
      margin:auto auto;
    }
  </style>
</head>
<body>
  <div class="parent">
    <div class="child"></div>
  </div>
</body>
</html>